Part Number Hot Search : 
AM3341 STA2065A SH7286 B10S4 MT4264 SE555FK AN5177 74HC17
Product Description
Full Text Search
 

To Download AN1636 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  AN1636/0603 1/42 AN1636 application note understanding and minimising adc conversion errors by microcontroller division applications 1 introduction the purpose of this document is to explain the different adc errors and the techniques that application developers can use to minimise them. the adc (analog to digital converter) is an important peripheral that connects the analog world to the digital world of microcontrollers. in this application note the adc embedded in the st7 microcontroller is used as an example, however the same principles to apply to other adcs. the accuracy of analog to digital conversion has an impact on overall system quality and effi- ciency. to be able to improve accuracy you need to understand the errors associated with the adc and the parameters affecting them. the adc itself, cannot ensure the accuracy of results, it depends on your overall system de- sign. for this reason, you need to do some careful preparation before starting your develop- ment. lots of parameters affect the adc accuracy depending on the application. some of these fac- tors are: pcb layout, voltage source, i/o switching and analog source impedance. 1
2/42 understanding and minimising adc conversion errors 1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 what is an adc? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2 adc block description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.1 analog input pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.2 analog multiplexer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.3 sample and hold circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.4 control block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.5 analog supply and reference . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3 adc terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.1 reference voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.2 resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.3 quantization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.4 monotonicity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.5 bipolar and unipolar adc input . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.6 hardware averaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.7 sampling theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4 sources of error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 4.1 power supply noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 4.2 power supply regulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.3 analog input signal noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 4.4 effect of analog source resistance . . . . . . . . . . . . . . . . . . . 19 4.5 effect of source capacitance . . . . . . . . . . . . . . . . . . . . . . . . . 20 4.6 effect of injection current . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 4.7 i/o pin cross-talk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 4.8 emi-induced noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 2
3/42 understanding and minimising adc conversion errors 5 different types of a/d converter errors . . . . . . . . . . . . . . . . . . 27 5.1 offset error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 5.2 gain error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 5.3 differential linearity error . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 5.4 integral linearity error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 5.5 total unadjusted error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 6 pcb layout recommendations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 7 how power saving modes affect the adc . . . . . . . . . . . . . . . . . . . 39 8 related documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 1
4/42 understanding and minimising adc conversion errors 1 what is an adc? an analog to digital converter is a peripheral which converts analog signals in a defined range to the digital outputs. in the real world, signals are mostly available in analog form. to use a microcontroller in this type of system, an adc is required, so that the signals can be converted to the digital values. the application software can then process the digital outputs and take decisions depending on the application or system requirements. the limitation imposed by the finite number of digital outputs decides how close the output is to the analog input. the more bits there are in the output, the closer the digital result will be to the analog signal. in other words, the resolution of the adc is defined by the number of bits in the digital result (8 bits, 10 bits etc) and the input voltage range. successive approximation method different techniques are available for converting analog signals to digital outputs. the succes- sive approximation method is the most popular technique. it is also known as successive ap- proximation register (sar) technique. this technique uses binary search method. it consists of a high speed comparator, dac (digital to analog converter), and control logic. refer to figure 1. figure 1. successive approximation block diagram the sar starts by forcing the msb (most significant bit) high (for example in an 8 bit adc it becomes 1000 0000), the dac converts it to v aref /2. the analog comparator compares the input voltage with v aref /2. if the input voltage is greater than the voltage corresponding to the msb, the bit is left set, otherwise it is reset. control logic + - comparator dac from sample and hold v aref n bit register v in digital output
5/42 understanding and minimising adc conversion errors v aref is the reference voltage used by adc for conversions. the details are mentioned in section 2.5 after this comparison is done, the next significant bit is set (=v aref /4) and a comparison is done again with the input voltage. the procedure is followed till all the bit positions are com- pared. at the end of all the bit comparisons we get the corresponding digital output for the analog input. the successive approximation steps are shown in table 1 . as you can see, the digital output obtained from the adc is b2h when the analog input is 3.5v. table 1. 8-bit adc successive approximation steps steps vin = 3.5v, v aref = 5v digital code dac output comparator output digital output (for steps) 1 1000 0000 2.5v 1 1000 0000 2 1100 0000 3.76v 0 1000 0000 3 1010 0000 3.13v 1 1010 0000 4 1011 0000 3.45 1 1011 0000 5 1011 1000 3.6 0 1011 0000 6 1011 0100 3.52 0 1011 0000 7 1011 0010 3.49 1 1011 0010 8 1011 0011 3.509 0 1011 0010 final output = b2h
6/42 understanding and minimising adc conversion errors 2 adc block description figure 2. adc block diagram the adc can be divided into the following blocks. a. analog input pins b. analog multiplexer c. sample and hold circuit d. successive approximation block e. control block f. analog supply/ reference 2.1 analog input pins several analog input pins are available to connect different analog signals. these are inter- nally multiplexed to use same sample and hold circuit and sar logic. ch2 ch1 eoc speedadon 0 ch0 adccsr ain0 ain1 ainx analog mux d4 d3 d5 d9 d8 d7 d6 d2 adcdrh 4 div 4 f adc f cpu d1 d0 adcdrl 0 1 00 0000 ch3 div 2 (a) (b) sample and hold circuit (c) successive approximation block (d) (e) v aref v ssa (f)
7/42 understanding and minimising adc conversion errors figure 3. electrical diagram of typical adc application configuring the analog pin choose any i/o port that has analog input capability (ain alternate function) and configure it as floating input. you can do this by writing 0 in the ddr and or register bits of the corre- sponding port. at reset, most of the st7 ios are configured by default as floating input. the pin should not be configured as floating input with pull-up. this configuration reduces the adc accuracy. the reason being the potential divider formed between the pull-up resist- ance and r adc . also some current flows from v dd to the analog source. this current is drawn from the v dd supply. also there is a potential divider formed between v dd , r pu and r ain, where r ain is the series impedance of the voltage source. figure 4. analog input with pull-up configuring the analog input as floating input with pull-up ( instead of floating input ) will cause more current to be drawn from the v dd supply . there is also an affect on the accuracy of the adc and the digital output converted by adc may not be accurate. ainx v dd i l 1 m a v t 0.6v v t 0.6v c adc v ain r ain 10-bit a/d conversion r adc c ain \/\/\/\/\/\/ c adc r adc v ssa (analog ground) \/\/\/\/\/\ v dd r pu not recommended v in current from v dd r pu should not be enabled. \/\/\/\/\/ r ain
8/42 understanding and minimising adc conversion errors analog pin input impedance r adc and c adc (hold capacitor) define the input impedance of the analog pins. r adc is also called as rss (resistance of sampling switch and internal trace/resistance). please refer to the sample and hold circuit explanation in section 2.3 . if the hold capacitor is fully discharged, the minimum input impedance is r adc . as the hold ca- pacitor starts to charge, the current flowing into the pin will reduce. if the hold capacitor is charged to a level equal to the external voltage there will be only minimal charging current flowing into the analog input. figure 5. analog input pin impedance the minimum input impedance of the analog pin is thus r adc . in the datasheet the maximum value of r adc is specified instead of a typical value, so that the user can calculate the affect of external resistance on sampling. this is explained in section 4.4 . 2.2 analog multiplexer the adc can have several analog input pins. these pins are connected internally to the an- alog to digital converter using the analog multiplexer. you can select each pin simply by writing in the appropriate control register. this allows a single sample and hold circuit and an- alog to digital converter block to be used to convert several analog input sources. this allows you to switch the analog channels and convert them one by one through software control. \/\/\/\/\/\/ c adc r adc v ssa (analog ground) input impedance zi = r adc + c adc
9/42 understanding and minimising adc conversion errors figure 6. analog multiplexer 2.3 sample and hold circuit the sample and hold circuit samples the input signal and charges the internal hold capacitor c adc to the voltage equal to v in through r adc . the analog pin is then disconnected and the voltage across the capacitor is then converted to digital code using successive approximation. figure 7. sample and hold circuit the sample and hold circuit consists of an electrically operated analog switch, internal charging resistance and hold capacitor. as soon as the adc conversion starts, the electrically operated switch is closed, connecting the hold capacitor to the analog input through the internal adc resistance r adc . this causes a charging current to flow into the analog input and the capacitor starts to charge. the time the switch remains closed is decided by the f adc . it is called sampling time . the sampling time is generally indicated in the datasheet as a multiple of f adc clock periods. time period t ad = 1/f adc ch[2:0] = 010 to sample and hold ain0 ain1 ain7 circuit analog input channels channel selection bits = 010 selects ain2 ain2 \/\/\/\/\/\/ electrically operated switch c adc r adc from analog multiplexer v ssa (analog ground) v in
10/42 understanding and minimising adc conversion errors figure 8. sample and hold timing and electrical diagram after the sampling time, the input capacitor has the same voltage as the input, the analog switch is then disconnected from the input and successive approximation conversion is started, to convert the voltage stored in the hold capacitor. this time is known as hold time . it is also expressed in multiples of t ad (1/f adc ). the total conversion time of the adc is the addition of sampling time and hold time. the sample and hold circuit is also known as track and hold. \/\/\/\/\/\/ electrically operated switch = closed c adc r adc v ssa v in hold time sampling time conversion time t ad = 1/f adc \/\/\/\/\/\/ electrically operated switch = open r adc v ssa v in time sar vc = v in sampling hold and conversion charging + leakage current leakage current sampling time note: please refer to product datasheet for sample and hold timing for adc. vc vc = voltage developed across capacitor. c adc capacitor charged=v in sar = successive approximation register block.
11/42 understanding and minimising adc conversion errors 2.4 control block this block consists of logic which controls the sample and hold circuit, starts the sar and then generates the conversion of the conversion complete signal for the microcontroller. 2.5 analog supply and reference depending on microcontroller and packaging, the analog supply pins are generally available on the package. v dda - analog supply ( or, v aref - reference voltage) v ssa - analog ground. if these pins are not available the v dda (analog supply) is shorted to v dd and v ssa is shorted to v ss internally. separate analog power supply pins are available to the user to improve the adc performance. it is recommended to put the filtering capacitor between v dda and v ssa so that power supply noise ( or ripples) on v dda are filtered and do not affect the adc accuracy. the v aref pins are available instead of v dda when the analog supply voltage can be different from the v dd . you may choose to keep v aref shorted to v dd if a dual supply is to be avoided. figure 9. analog supply block as these pins provide power supply to the analog block, you should not connect a resistor in series with v aref . this will cause the voltage to drop due to the current flowing through the re- sistor and hence will affect the accuracy of the adc. do not leave the v dda /v aref , v ss pins unconnected. if your application does not use the adc, you must connect these pins as follows: v dda must be connected to v dd, and v ssa v ss v dd 0.1 m f 10pf v dd st72xxx v dda v ssa power supply source st7 digital noise filtering external noise filtering 1 to 10 m f 0.1 m f 10pf (if needed) (if needed) /\/\/\/\/\/\ /\/\/\/\/\/\ v ssa v aref v dd not recommended recommended st72xx
12/42 understanding and minimising adc conversion errors must be connected to the v ss of the microcontroller. v ssa cannot have any voltage other than v ss . make sure that v aref is not greater than v dd . there is a protection diode from v aref to v dd . similarly v ssa should not be less than or greater than v ss . there are protection diodes con- nected back-to-back between v ssa and v ss . figure 10. multisupply configuration 3 adc terminology there are some terms associated with the adc which we should understand before we move further. 3.1 reference voltage the adc requires a reference voltage to which the analog input is compared to produce the digital output. the digital output is the ratio of the analog input with respect to this reference voltage. digital value =((analog input voltage)/(reference voltage high- reference voltage low)) * (2 n -1) where n = number of bits of adc digital output. the reference voltage is the maximum input voltage that can be converted by the adc. v aref is the reference voltage for the adc. if v aref is not available v dda is used as reference. for example: for 10-bit adc, v in =1v, v aref =5v, digital value = (1v/5v ) *1023 = 204d = 0cch 3.2 resolution the adc resolution is defined as the smallest incremental voltage that can be recognized and hence it causes a change in the digital output. it is usually expressed as the number of bits output by the adc. v aref v ssa v aref v dd v ss back to back diode between grounds v ssa
13/42 understanding and minimising adc conversion errors hence an adc which converts the analog signal to a 10-bit digital value, has a resolution of 10 bits. the smallest incremental voltage that can be recognized is expressed in terms of lsb. 1lsb = (v aref - v ssa )/2 n where lsb = least significant bit. n = number of bits output by the adc. v aref = reference voltage v ssa = analog ground an adc which has n bit digital output, provides 2 n digital values. it includes both 0 and 2 n -1. with a 5v reference voltage, the resolution is 5 (volts) /2 10 = 5 (volts)/1024 = 4.88 mv. this means that for a change in 4.88mv analog input the adc converted digital value will change by 1lsb. in reality there are 2 n -1 steps. so the actual resolution is 1lsb = (v aref - v ssa )/(2 n -1). as in practice there is very little difference between the two calculated values because n is quite a large number, both definitions are used. figure 11. resolution representation 3.3 quantization in theory, the continuous analog signal can be broken into an infinite number of digital steps, but the quantization of an analog signal by the adc can be done only in the finite number of steps which can be produced by the adc. digital output analog input 00h 3ffh v aref (n+1) v aref n n n+1 resolution v aref
14/42 understanding and minimising adc conversion errors the quantization error is the error introduced because of the process of quantization. ideally any analog input voltage can be maximum of 1/2 lsb away from its nearest digital code. so the quantization error is 0.5lsb for the adc. figure 12. quantization of analog signal 3.4 monotonicity monotonicity is defined as a property of the adc transfer function, which ensures that con- verted digital values will never decrease if the analog input does not decrease and conversion results will never increase if the analog input does not increase. this property is inherent to the design of the adc, subject to the accuracy specified in the datasheet in each case. 3.5 bipolar and unipolar adc input adcs that can accept both positive and negative analog signals are known as bipolar. v in v ssa digital output (decimal steps) ideal transfer curve 1 1 1lsb 0.5lsb -0.5lsb 2 step width center of step = 0 quantization error 0 quantization error vin
15/42 understanding and minimising adc conversion errors adcs that can accept only positive input voltage are known as unipolar. adcs embedded in microcontrollers are unipolar, as the input cannot decrease below the analog ground. st7 microcontrollers have unipolar input adcs and have an input range from 0v to v aref . in an 8-bit adc, for example, C a unipolar adc with an input range of 0v to 5v will output the digital code 00h for 0v and ffh for 5v. C a bipolar adc with an input range of -5v to +5v will output the digital code 00h for -5v, 80h for 0v and ffh for +5v. figure 13. bipolar and unipolar adc transfer curves 3.6 hardware averaging to improve adc accuracy, you can perform a number of adc conversions and use the av- erage of these conversions to obtain more accurate digital output. in hardware averaging adcs, this technique is embedded in the hardware and the averaging is done by the hardware itself. the final digital output received from adc is actually the average of the conversions. this hardware averaging technique is implemented in some st7 microcontrollers. the con- version time is thus increased as several conversions are performed. 3.7 sampling theorem the sampling theorem states that to convert the analog signal with frequency f, the adc sampling frequency must be at least twice the analog signal frequency. so the sampling fre- quency must be at least 2*f. digital output analog input bipolar adc unipolar adc digital output analog input 00h 80h ffh 00h ffh transfer curve transfer curve
16/42 understanding and minimising adc conversion errors sampling the signal at twice the analog signal frequency will not result in a loss of information. if sampling frequency is less, then the information will be lost. this is a standard theorem that applies to adcs in general. for example: an adc with a conversion time of 10s can be used to sample an analog signal with a time period of 20s, i.e. 50khz. (1/20s). 4 sources of error 4.1 power supply noise the analog power supply is used as the reference voltage for conversion. as the adc output is the ratio between the analog signal voltage and the supply voltage, any noise on the analog reference will cause a change in the converted digital value. for example: with a 5v supply (analog reference) and 1v signal, the converted result is (1/5)*1023 = 204d = cch but with 40mv ripple peak-to-peak in the power supply, the converted value is (1/5.04)*1023 = 202d = cah (when v aref was at its peak). the smps (switch mode power supply) normally has internal fast switching power transistors. this introduces high frequency noise in the output. the switching noise is in the range of 15- 1mhz. you can filter this noise by putting low value capacitors (10pf - 22pf) on the power supply rail. low value capacitors have low reactance whereas high value capacitors have high reactance. linear regulators have better output in terms of noise. the mains must be stepped down, rec- tified and filtered and then fed to linear regulators. it is highly recommended to have the filter capacitors at the rectifier output. please refer to the datasheet of the linear regulator in each case. generally 0.01uf is recommended. if you are using a switching power supply, it is recommended to have a linear regulator to supply the analog section. it is recommended to connect capacitors, with good high frequency characteristics, between the power and ground lines, placing 0.1uf and optionally, if needed 10pf capacitors as close as possible to the st7 power supply pins and a 1 to 10uf capacitor close to the power source.
17/42 understanding and minimising adc conversion errors figure 14. power supply filtering the capacitors allow the ac signals to pass through them. the small value capacitors filter high frequency noise and the high value capacitors filter low frequency noise. ceramic capac- itors are generally available in small values (1pf to 0.1 f) and small voltages 16v to 50v. it is recommended to place the ceramic capacitors close to the main supply pins (v dd & v ss and analog supply pins (v dda & v ssa ). these filter the noise induced in the pcb tracks. small ca- pacitors can react fast to current surges and discharge quickly for fast current requirements. tantalum capacitors can also be used along with ceramic capacitors. high value capacitors (10f to 100f) which are generally electrolytic, you can use them to filter low frequency noise. it is recommended to put them near the power source. you can also filter high frequency noise using a ferrite inductance in series with the power supply. ferrites cause low dc loss (negligible) unless the current is high. this is because the series resistance of the wire is very low. but for high frequency, the impedance offered is high. in most st7 microcontrollers the v dd & v ss pins are placed close to each other. similarly v aref & v ssa pins are placed closed to each other. this allows you to put a capacitor very close to the microcontroller with very short leads. for multiple v dd & v ss pins, use separate decoupling capacitors. 4.2 power supply regulation the power supply should have good line and load regulation. as the adc uses v aref as the analog reference and the digital value is the ratio of analog input signal and v aref . so v aref must remain stable at different loads. whenever the load is increased by switching-on a part of the circuit, the increase in current must not cause the voltage to decrease. if the voltage remains stable over a wide range of cur- rent the power supply has good load regulation. v ss v dd 0.1 m f 10pf v dd st72xxx v dda v ssa power supply source st7 digital noise filtering external noise filtering 1 to 10 m f 0.1 m f 10pf (if needed) (if needed)
18/42 understanding and minimising adc conversion errors if the voltage decreases, the decrease in v aref changes the ratio of the analog signal to v aref . digital output = (v in /v aref ) * (2 n -1) a change in v aref will make a change in the digital output. for example: for the l7805 voltage regulator, (please refer to the l7805 datasheet for details). line regulation is 20mv typical for i(load) between 1ma to 100ma. similarly, line regulation is 18mv typical for rectified voltage between 7v to 20v. 4.3 analog input signal noise the analog signal to be converted may have some noise superimposed on it. there may be a high frequency noise signal. it is recommended to connect a 10nf capacitor to the analog input signal. you can also add a low pass filter but this will affect f ain , so you should use this only if the input signal frequency is low. f ain is the frequency of the analog input signal. for other details refer to section 4.5 .
19/42 understanding and minimising adc conversion errors figure 15. noise in analog input signal 4.4 effect of analog source resistance the impedance of the analog signal source or series resistance (r ain ) between source and pin will cause a voltage drop across it because of current flowing into the pin. the r adc and c adc form an rc network. the charging of the capacitor is controlled by r adc . when there is r ain in series, the effective value of charging of c adc will be governed by r adc +r ain , so the charging time constant will become (r adc +r ain )*c adc . the sampling time for adc should be greater than 10 times the rc time constant. please refer to the expla- nation in section 4.5 . with external input resistance, the sampling time required by the adc will also increase. the adc has a fixed sampling time depending on f adc . with the addition of source resistance, the time required to fully charge the hold capacitor will increase. if the sampling time is less than the time required to fully charge the c adc through r adc +r ain, the digital value converted by the adc will be less than the actual value. sampling time > 10*(r adc +r ain )*c adc expected /ideal signal at analog input actual signal at analog input 10mv vp-p ~2 lsb 10nf adc v ain recommended configuration with slow input signal ainx
20/42 understanding and minimising adc conversion errors figure 16. effect of source impedance on internal sampling 4.5 effect of source capacitance you have to take the capacitance and resistance at the source into account when converting analog signals . the source resistance and capacitance form an rc network and the adc con- version results may not be accurate unless the external capacitor is fully charged to the level of the input voltage. the external capacitance at source is denoted by c ain . \/\/\/\/\/\/ c adc r adc v ssa \/\/\/\/\/\/ r ain v ain vc vc increased time to charge c adc to v in time time v in vc = voltage across hold capacitor c adc time constant = 10*(r ain +r adc )*c adc correct time to charge c adc to v in time constant = 10*r adc *c adc (analog ground) vc ainx ainx = analog input pin c adc = the hold capacitor of the adc refer to datasheet for values for r adc and c adc
21/42 understanding and minimising adc conversion errors figure 17. adc input with r ain , c ain the external capacitance will not allow the voltage of the analog input to be exactly the same as v in if it is not fully charged by the analog source. if the analog input signal varies, then the analog signal frequency (f ain ) should be such that the time period of this analog signal is at least 10 * r ain * c ain . figure 18. recommended r ain , c ain values t ain = time period of analog signal = 1/f ain t ain >= 10 * r ain * c ain . f ain = 1/ t ain <= 1/ (10 * r ain * c ain ) for example: for r ain = 10k, c ain = 10nf t ain = 10 r ain * c ain = 10 * 10k* 10n = 1000s = 1ms f ain = 1/t ain = 1/1ms = 1khz maximum. ainx v ain r ain c ain st72x cp cp = parasitic capacitance c ain = source capacitance 0.1 1 10 100 1000 0.01 0.1 1 10 f ain (khz) max. r ain (kohm) cain 10 nf cain 22 nf cain 47 nf
22/42 understanding and minimising adc conversion errors figure 19. effect of external r and c. the voltage across the capacitor follows the following equation: vc = v in (1 - e -t/rc ) vc = voltage across capacitor v in = voltage from voltage source e = exponential constant = 2.71 (approx.) t= time, after which voltage across the capacitor is to be calculated. r = resistance used to charge the capacitor c= capacitance value. r*c = time constant of rc network table 2. voltage across the capacitor it should be noted that when the ratio of t/rc increases, the voltage developed across the ca- pacitor becomes nearly equal to v in . the conversion result will be correct only when the ca- pacitor is fully charged. therefore, t >= 10*r*c. t/rc vc/ v in vc 1 (1- (2.71) -1 )0.63* v in 2 (1- (2.71) -2 )0.86* v in 3 (1- (2.71) -3 )0.94* v in 4 (1- (2.71) -4 )0.98* v in 8 (1- (2.71) -8 ) 0.9996* v in 10 (1- (2.71) -10 ) 0.9999vin input signal signal at analog input (=across external capacitor not charged to v in cain)
23/42 understanding and minimising adc conversion errors the parasitic capacitance formed at the analog input because of track paths etc. appears in parallel with external capacitance. so it must be added to c ain . however when the parasitic capacitance value is much less than c ain , it can be ignored. when c ain is small (for example c ain < 100*c adc ), it may not be able to hold the v in voltage effectively. so when adc conversion is started, c adc will appear across the c ain through r adc causing c ain to effectively discharge. so we need to consider the sampling time re- quired with external resistance and capacitance. figure 20. r ain vs f adc for example: with r ain =10k, c ain (or cparasitic) = 10pf, c adc =6pf time for charging external capacitor = r ain *c ain = 10k* 10pf = 100ns 10*r ain *c ain = 1us. time for charging hold capacitor c adc = (r ain +r adc )* c adc rc = 12k*6pf =72ns 10rc = 720ns = 0.72us total time = 1us + 0.72s = 1.72s. (approx.) so, for adcs with f adc =2mhz, sampling time = 4*t ad = 2s. with total time of 1.72s obtained with r ain and cparasitic, the sampling time of 2s is already at its upper limit. if the resistance is higher, f adc must be decreased to increase the sampling time. so f adc less than 2mhz can be used. it can be noted that for f adc = 1mhz, r adc can be up to 20 kohm.
24/42 understanding and minimising adc conversion errors at lower f adc, we can start the adc conversion as the sampling time is long enough to charge both c adc and c ain (or cparasitic). 4.6 effect of injection current st microcontrollers have robust tolerance of additional leakage current introduced on analog input signals as an effect of negative injection current. negative injection current on any an- alog pin (or closely placed digital input pin) may introduce leakage current into the adc input. the worst case is the adjacent analog channel. negative injection current is introduced when v in 25/42 understanding and minimising adc conversion errors figure 21. effect of injection current this demonstrates that the source impedance should be as small as possible to obtain max- imum accuracy. with no negative injection current, no loss of accuracy is expected. positive injection current is introduced when v in > v dd . therefore current flows into the i/o pin. positive injection current within the limit does not cause any loss of accuracy. minimizing injection current check the application to verify if any digital or analog input voltages can be less than v ss or v ssa . in this case negative injection current will flow from the pins. negative injection current will have greater affect on the accuracy, when a digital input is close to the analog input being converted. it is recommended to connect a schottky diode from v ssa to the io which can have the neg- ative injection current. 4.7 i/o pin cross-talk switching the i/os may induce some noise in the analog input of the microcontroller. this is because of capacitive coupling between the i/os. the cross-talk may be introduced by pcb tracks running close to each other or crossing over each other. within the microcontroller there can be non-negligible effect on i/os because of switching etc. internally switching digital signals and i/os introduces high frequency noise. if high sink i/os are switched, this may induce some voltage dips in the power supply because of the current surges. a digital track crossing over an analog input track on the pcb may affect the analog signal. v in < v ss injection current ain0 leakage current \/\/\/\/\/\/ vain r ain adc microcontroller v ssa ain1
26/42 understanding and minimising adc conversion errors figure 22. cross-talk between i/os 4.8 emi-induced noise electromagnetic emissions from neighboring circuits may introduce high frequency noise into an analog signal because the pcb tracks may act like an antenna. you can reduce the emission noise by proper shielding and layout techniques. the possible sources of emissions must be physically separated from the receptors. you can separate them electrically by proper grounding and shielding. you can minimize the reception noise by using filtering techniques so that high frequency noise is filtered. figure 23. emi sources analog-in digital i/o analog-in digital i/o analog-in digital i/o digital and analog signal passing close to each other digital and analog signal tracks crossing each other on different side of the pcb recommended grounding between signals shielding the analog signal by placing ground tracks across it helps reduce noise produced by cross talk etc. analog source electro- magnetic noise internal noise i/o coupled noise induced noise from pcb tracks adc microcontroller
27/42 understanding and minimising adc conversion errors shielding placing ground tracks alongside sensitive analog signals provides shielding on the pcb. the other side of the two-layer pcb should also have a ground plane. this prevents interference and i/o cross-talk affecting the signal. signals coming from distant locations (like sensors etc) should be connected to the pcb using shielded cable. care should be taken to minimize the length of the paths of these types of signal on the pcb. the shield should not be used to carry the ground reference from the sensor or analog source to the microcontroller. a separate wire should be used as ground. the shield should be grounded at only one place near the receiver such as the analog ground of the microcontroller. grounding the shield at both the ends (source and receiver) may cause ground loops to be formed and making the current flow from the shield. figure 24. shielding if the current is flowing through the shield, it will act like an antenna and the purpose of shielding will be lost. the shielding concept also applies to grounding the chassis of the application if it is metallic. this also helps to remove emi and emc interference. in this case the mains earth ground is used to shield the chassis. similarly dc ground can also be used for shielding in case earth ground is not available. 5 different types of a/d converter errors different error types are specified for a/d converters. these errors are normally expressed as multiples of lsb for easy reference. the resolution in terms of voltage depends on the refer- ence voltage. you can calculate the error in terms of voltage by multiplying the ( number of lsb ) with ( voltage corresponding to 1lsb ). adc grounding the shield at the receiver end only adc ground currents do not ground the shield at both ends not recommended recommended sensor sensor
28/42 understanding and minimising adc conversion errors 5.1 offset error this is defined as the deviation between the first actual transition and the first ideal transition. the first transition is when the digital output of adc changes from 0 to 1. in an ideal case we should get a digital output of 1, when the analog input is between 0.5 lsb to 1.5lsb. the first transition in an ideal case will be at 0.5 lsb. offset error is represented as e o . example 1: in a 10-bit adc, ideally 2.44mv (0.5 lsb = 0.5 * 4.88mv) input should generate a corre- sponding digital output of 1. but in practice the adc may still show the reading as 0. if we get a digital output of 1 from an analog input of 10mv, then: offset error = actual transition - ideal transition e o = 10mv - 2.44mv = 7.56 mv e o = 7.56mv / 4.88 mv = 1.54 lsb when an analog input voltage of greater than 0.5lsb generates the first transition, then the offset error will be positive. figure 25. positive offset error representation when the analog input voltage v in = v ssa and the adc generates a non-zero digital output then the offset error will be negative. this will mean that theoretically (or by extrapolation) a negative voltage will generate the first transition. as specified in the datasheet, any voltage less than v ssa will cause the digital output to be 0. v in 1 digital output (decimal steps) ideal transfer curve e o = offset error (positive) actual transfer curve e o 0.5lsb
29/42 understanding and minimising adc conversion errors figure 26. negative offset error representation 5.2 gain error gain error is defined as the deviation between the last actual transition and the last ideal tran- sition. gain error is represented as e g . the last actual transition means the transition from 3fe to 3ff for a 10-bit adc. in an ideal case we should get a transition from 3fe to 3ff from a 10-bit adc, when the analog input is equal to v aref -0.5lsb. so for v aref = 5v, last ideal transition shall be at 4997.12 mv. if adc provides the 3ffh reading for v in < v aref -0.5lsb, then we have a negative gain error. example for a 10-bit adc and v aref =5v if v in = 4990 mv generates transition from 3fe to 3ff then, gain error e g = last actual transition - ideal transition e g = 4990mv - 4997.12 mv e g = - 7.12 mv e g = (-7.12mv / 4.88mv) lsb = -1.45 lsb v in 1 ideal transfer curve e o = offset error (negative) digital output e o actual transfer curve 0.5lsb
30/42 understanding and minimising adc conversion errors figure 27. negative gain error representation if we do not get full scale reading ( 3ff for a 10-bit adc ) for v in equal to v aref the gain error will be positive. this means theoretically (or by extrapolation), a voltage greater than v aref will cause the last transition. figure 28. positive gain error representation 5.3 differential linearity error differential linearity error (dle) is defined as the maximum deviation between actual steps and the ideal steps. here ideal is not for the ideal transfer curve but for the resolution of the adc. dle is represented as e d. digital output (decimal steps) ideal transfer curve e g = gain error (negative) actual transfer curve e g 1023 1022.5 v in lsb digital output (decimal steps) ideal transfer curve e g = gain error (positive) actual transfer curve e g 1023 1022.5 lsb v in
31/42 understanding and minimising adc conversion errors dle = actual step width - 1lsb ideally analog input voltage change of 1lsb should cause a change in the digital code. if an analog input voltage greater than 1lsb is required for a change in digital code, then the adc has the differential linearity error. dle thus corresponds to additional maximum voltage that is required to change one digital code to the next digital code. dle is also known as dnl, differential non-linearity error. example: for a range of analog input we should get the same digital output. ideally the step width should be 1lsb. suppose we get same digital output for a range of analog input voltage 1v to 1.010v then the step width will be 1.010v-1v = 10mv. dle is thus the voltage difference between the higher (1.010v) and lower analog voltage (1v) subtracted by the voltage corresponding to 1lsb. figure 29. differential error representation with a 10-bit adc and v aref = 5v, an analog input of 1v can provide results varying from cbh to cdh. similarly for 1.010v, i.e. 206d = ceh, the results may vary from cdh to cfh. so, total voltage range corresponding to the step cdh is 1.010 v - 1v = 10mv e d = 10mv - 4.88 mv e d = 5.12 mv v in v ssa 1 digital output (decimal steps) actual transfer curve 1lsb ideal e d ideal transfer curve e d = differential linearity error 1lsb e d (negative) positive note: in this example the actual curve is shown to have an offset error from ideal curve.
32/42 understanding and minimising adc conversion errors e d = (5.12mv/4.88mv) lsb e d = 1.04 lsb here we assume that any voltage greater than 1.010 v will not result in the digital code equal to cdh. when the step width is less than 1lsb, dle will be negative. 5.4 integral linearity error integral linearity error is maximum deviation between any actual transition and the endpoint correlation line. ile is represented as e l. the endpoint correlation line can be defined as the line on the a/d transfer curve that con- nects the first actual transition and last actual transition. ile is the deviation from this line for each transition. the endpoint correlation line thus corresponds to the actual transfer curve and has no relation to the ideal transfer curve. ile is also known as inl, integral non linearity error. ile is the integral of dle over the full range. figure 30. integral error representation example: if we get the first transition from 0 to 1 at 10mv ( offset error ) and we get the last transition (3fe to 3ff) at 4.990v (gain error) then the line on transfer curve connecting the actual digital code 1 and the actual digital code 3ff will be the endpoint correlation line. v in v ssa 1 digital output (decimal steps) e l = integral linearity error transfer curve actual e l endpoint correlation line 1023
33/42 understanding and minimising adc conversion errors 5.5 total unadjusted error tue is defined as the maximum deviation between the actual and the ideal transfer curves. it is a parameter which specifies the total errors that can occur causing maximum deviation be- tween the ideal digital output and actual digital output. it is the maximum deviation recorded between ideal expected value and actual value obtained from the adc for any input voltage. tue is represented as e t. tue is not the sum of e o , e g , e l , e d . the offset error affects the digital result at lower volt- ages whereas the gain error affects the digital output for higher voltages. example: with a 10-bit adc and v aref =5v and 1v input, the ideal result is cch. but if on conversion we get the result ceh, this deviation may be because of offset, dle and inl errors occurring si- multaneously. tue = absolute (actual value - ideal case value). = ceh - cch = 2h figure 31. total unadjusted error v in v ssa 1 digital output (decimal steps) ideal transfer curve et = total unadjusted error actual transfer curve et
34/42 understanding and minimising adc conversion errors using error parameters 1. the tue is not the sum of all the errors e o , e g , e l , e d . it is the maximum error which can occur between ideal and expected digital values. it can be the effect of either a single error or two errors occuring simultaneously. 2. as ile is the integral of dle, it can be considered as indicative of maximum error. do not add both dle and ile together to calculate the maximum error which can occur at any dig- ital step. 3. integral linearity error is the maximum deviation between any actual transition and the end point correlation line. so it represents the linearity of the adc. 4. ile and dle are dependent on the adc design. it is difficult to calibrate them. 5. the ile and dle can be minimized by doing multiple conversions and then averaging. 6. offset and gain errors can be easily cancelled / compensated using software techniques. 7. the maximum values for errors specified in datasheet are the worst error values measured in the laboratory test environment for full voltage range. 8. as already mentioned, all the adcs provide the digital converted output in ratio with the ref- erence voltage. to convert analog voltage accurately, the adc needs to have an accurate v aref otherwise the digital output received may not be the correct value. example: in the widely used 7805 voltage regulator, the datasheet (l78m05c) specifies vo min.= 4.8v and vomax = 5.2v. this variation is 0.2v from required 5v. hence a variation of 200mv. with an analog input of 1v and with v aref =5v, the expected digital output should be (1/5)*1023 = 204d = cch but if v aref = 4.8v, the digital output = (1/4.8)*1023 = d5h so the power supply variation has caused a change of d5-cc = 9. in this case to measure the true input voltage, all the relevant parameters must be verified and crosschecked. for example, if a precision voltage regulator such as the l78m05ab is used, it provides io=350ma and vomin=4.9v, vo max = 5.1v. 6 pcb layout recommendations for best adc conversion accuracy, you should follow these pcb layout guidelines. 1. separate the analog and digital layouts
35/42 understanding and minimising adc conversion errors it is recommended to separate the analog and digital circuitry on the pcb. they should be placed in different parts of the pcb. this also avoids tracks crossing each other. the tracks carrying digital signals may introduce high frequency noise in analog signals because of cou- pling. the digital signals produce high frequency noise because of fast switching. coupling of the capacitive nature is formed because of the metal connections (tracks) sepa- rated by the dielectric provided by the pcb base (glass, ceramic or plastic). it is recommended to use different planes for analog and digital ground. if there is a lot of an- alog circuitry then an analog ground plane is recommended. analog ground must be placed below the analog circuitry. figure 32. separating the analog and digital layouts 2. separate power supplies for analog and digital circuits it is desirable to have separate analog and digital power supplies in cases where there is a lot of analog and digital circuits external to the microcontroller. depending on the microcontroller package, different analog and digital power supply and ground pins are available. internally v aref and v dd pins are not connected except for protection through schottky diodes. these pins can be powered from separate power supplies. in low pin-count packages, separate analog and digital supply and ground pins may not be available. in this case they are internally shorted. so v dda and v dd are internally connected in packages which have fewer pins. as mentioned earlier, if you use a switching type power supply for the digital circuitry, you should use a separate linear supply for the analog circuit. also, if you expect a lot of noise on the dc power supply due to i/o switching etc, a separate supply for the analog section is preferable. analog circuitry digital circuitry micro controller analog ground digital ground (noisy and noise generating) (affected by noise) power supply
36/42 understanding and minimising adc conversion errors important : separate analog and digital supplies are recommended only if the microcontroller has v aref pins for the adc reference voltage (instead of v dda ). if the microcontroller does not have v aref pins, then the difference between v dda and v dd should not be more than the difference specified in the datasheet (check the absolute maximum ratings). generally the dif- ference between v dda and v dd is specified as 50mv, hence separate supplies are not recom- mended. figure 33. separating the analog and digital supplies ac mains smps v aref v ssa v ss linear regulator analog circuit microcontroller v dd
37/42 understanding and minimising adc conversion errors 3. connect analog and digital power supplies in a star network it is recommended to connect the analog and digital grounds in star network. this means that you must connect the analog and digital grounds only at one point. this avoids noise being in- troduced in the analog power supply section, because of digital signal switching and also avoids current surges affecting the analog section. figure 34. star connection for analog and digital supplies 4. using separate pcb layers for supply and ground two-layer pcbs for two layer pcbs it is recommended to provide a maximum area for the ground. the power supply (v dd , v dda ) should run through thick tracks. the ground area between two layers can be shorted together via multiple connections in the overlap region if they are same ground sig- nals. the unused area of the pcb can be filled with the ground area. the other convention is to fill the unused area of pcb on one layer with positive supply (v dd ) and unused area on other plane for ground. the advantage is reduced inductance for power and ground signals. maximum ground area on pcb provides a good shielding effect and re- duces the electromagnetic induction susceptibility of the circuit. multilayer pcbs wherever possible, try to use multilayered pcbs and use separate layers on the pcb for power and ground. the v dd , v ss pins of the various ics can be directly connected to the power supply analog circuit analog ground digital circuit digital ground digital current analog current
38/42 understanding and minimising adc conversion errors power planes thus reducing the tracks needed to connect the supply and ground. longer tracks will have a high inductive effect. the analog ground can be connected at one point to this ground plane, this should be near to the power supply. a full ground plane provides a good shielding effect and reduces the electromagnetic induc- tion susceptibility of the circuit. figure 35. multlayer pcb configurations the disadvantage of multilayer pcbs is the higher cost of manufacturing and the fact that they are more difficult to debug. single-layer pcbs single-layer pcbs are used to save cost. they can be used only in simple applications when the number of connections is very limited. it is recommended to fill the unused area with ground. jumpers can be used to connect different parts of the pcb. 5. component placement and routing place the components and route the signal traces on the pcb to shield the analog inputs. an- alog signal paths should run over the analog ground plane. components like resistors and capacitors must be placed with their leads very short. surface mounted devices (smd), resistors and capacitors can be used. smd capacitors can be placed close to the microcontroller for decoupling. the tracks for the power should be wide, as the series resistance of these tracks will cause the voltage drop if the tracks are narrow. narrow power tracks will have non-negligible finite resist- ance. high load current will cause some voltage drop across these tracks. 1. top layer and bottom layer for smd components 2. second layer as power plane 3. third layer ground layer 1. top layer and bottom layer for smd components 2. second layer as digital ground plane. 3. third layer as analog ground 1. top layer and bottom layer for components and ground plane digital and analog ground connected at one point near power supply 2. second and third layer for tracks ( analog and digital ) there will be tracks passing vertically through the ground and supply planes. smd: surface mounted devices
39/42 understanding and minimising adc conversion errors quartz crystals must be surrounded by ground tracks/plane. the other side of the two layer pcb below the crystal should preferably be covered by the ground plane. most crystals have a metallic body that should be grounded. the crystal should be placed close to the microcon- troller. surface mounted crystals are available and can be used. 6. software considerations do not toggle digital outputs on the same i/o port as the a/d input being converted. this will introduce switching noise into the analog inputs. toggling high sink i/os may introduce high frequency noise in the power supply, this may af- fect the conversion results. 7 how power saving modes affect the adc wait mode adc can be used when the microcontroller is in wait mode. you can take advantage of the re- duced internal noise in the microcontroller to improve adc conversion results. halt mode entering halt mode will disable the adc, irrespective of whether the adon bit is set or not. this is because executing the halt instruction shuts down the adc. exiting from halt mode requires some stabilization time before adc conversion should be started. this conversion time is very small. please refer to the datasheets. table 3. summary table st7 modes oscillator/cpu/peripheral status effect on adc oscil- lator cpu mccsr- oie bit mccsr- sms bit adc run on on x reset on use the adc as mentioned in da- tasheet. slow on on x set on take care that f adc does not fall below f adc min. wait on off x reset on if adc has exit-from wait capa- bility, this mode is recommended. slow-wait on off x set on if adc has exit-from wait capa- bility, this mode is recommended.
40/42 understanding and minimising adc conversion errors note: reset=0, set=1 rules and recommendations for using the adc in power saving mode different power saving modes for st7 can be selected depending on power saving require- ments of the application, the following rules and recommendations should be applied when using the adc. 1. when switching to slow mode from run mode care should be taken that the f adc should not fall below the f adc minimum specified. otherwise the conversion results are not guaranteed. similarly when application switches to slow-wait mode after recovering from wait mode, f adc shall be in specified range. 2. similarly, when switching back from slow mode to run mode (or slow-wait to wait mode), if adc conversion is intended, the f adc should not increase above the f adc max specified in the data sheet. conversion results are not guaranteed outside the operating frequency range of adc. 3. for adcs with wait mode wake up capability, it is recommended to use wait mode for adc conversion. this will improve results because the cpu is off in wait mode, and this reduces the noise generated by digital switching. 4. if the adc does not have an interrupt capability for waking up from wait mode, then any other interrupt (for example a timer interrupt) can be used to take advantage of the reduced internal noise in wait mode. before entering wait mode, adc conversion can be started, and the results can be read after exit from wait mode. 5. if adc is off/disabled, leakage current can flow into the adc if the analog channels are con- nected to the analog input pins. this is because of finite impedance of io pins. 6. if the adc is not used in the application, and you want to save power consumption, then you must disable the adc through software. 7. when entering a power saving mode, disable the adc if you do not need it to perform con- version while the microcontroller is in power saving mode. if the adc is not disabled before active-halt on off set x off exit from halt mode requires sta- bilization time before conversion starts. halt off off reset x off exit from halt mode requires sta- bilization time before conversion starts. st7 modes oscillator/cpu/peripheral status effect on adc oscil- lator cpu mccsr- oie bit mccsr- sms bit adc
41/42 understanding and minimising adc conversion errors entering power saving mode (except halt or active-halt), the internal analog circuit will con- sume some current. 8 related documentation you can refer to the following application notes for additional useful information: an435: designing with microcontrollers in noisy environment an898: emc general information an901: emc guidelines for microcontroller - based applications an1015: software techniques for improving microcontroller emc performance
42/42 understanding and minimising adc conversion errors the present note which is for guidance only aims at providing customers with information regarding their products in order for them to save time. as a result, stmicroelectronics shall not be held liable for any direct, indirect or consequential damages with respect to any claims arising from the content of such a note and/or the use made by customers of the information contained herein in connection with their products. information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the co nsequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specifications mentioned in this publicati on are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics prod ucts are not authorized for use as critical components in life support devices or systems without the express written approval of stmicroele ctronics. the st logo is a registered trademark of stmicroelectronics ? 2003 stmicroelectronics - all rights reserved. purchase of i 2 c components by stmicroelectronics conveys a license under the philips i 2 c patent. rights to use these components in an i 2 c system is granted provided that the system conforms to the i 2 c standard specification as defined by philips. stmicroelectronics group of companies australia - brazil - canada - china - finland - france - germany - hong kong - india - israel - italy - japan malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - u.s.a. http://www.st.com


▲Up To Search▲   

 
Price & Availability of AN1636

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X